﻿@using PagedList;
@using PagedList.Mvc;
@model IPagedList<Project_2._2.Models.DatXe>
@{
    ViewBag.Title = "Quản Lý đặt Xe";
    Layout = "~/Views/Shared/_AdminLayoutPage.cshtml";
}
<link href="~/Content/Admin-content-right.css" rel="stylesheet" />
<script src="~/Script/Jquery_Table_Sort/jquery-latest.js"></script>
<script src="~/Script/Jquery_Table_Sort/jquery.tablesorter.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $("table").tablesorter({ sortList: [[0, 0]], headers: { 10: { sorter: false } } });
    });

</script>

<style>
    .search {
        width: 100%;
        height: 40px;
        padding: 10px 0 10px 10px;
        float: left;
    }
</style>

<div class="grid_12">
    <div class="block-border">
        <div class="block-header">
            Quản Lý đặt Xe
        </div>
        <div class="block-content" style="overflow:scroll">

            <div class="search">

                @using (Html.BeginForm("Default", "BookCar", FormMethod.Post, new { id = "Form" }))
                {
                    List<SelectListItem> record = new List<SelectListItem>();
                    int macdinh = 10;
                    if (ViewBag.record != null)
                    {
                        macdinh = int.Parse(ViewBag.record);
                    }
                    else
                    {
                        macdinh = 10;
                    }
                    for (int i = 10; i < 50; i+=10)
                    {
                        if (macdinh == i)
                        { record.Add(new SelectListItem { Text = i + " Dòng", Value = i.ToString(), Selected = true }); }
                        else
                        { record.Add(new SelectListItem { Text = i + " Dòng", Value = i.ToString() }); }
                    }

                    <span>Dòng Hiển Thị </span> @Html.DropDownList("Record", record, new { @class = "select", onchange = "SelectedIndexChanged()" })

                    <span style="padding:0 10px 0 260px"> Từ Khóa </span> @Html.TextBox("KeyWord", null, new { @class = "Textbox", @placeholder = "Nhập từ khóa ..." })
                    List<SelectListItem> SearchBy = new List<SelectListItem>();
                    SearchBy.Add(new SelectListItem { Text = "Họ Tên", Value = "HoTen", Selected = true });
                    SearchBy.Add(new SelectListItem { Text = "Email", Value = "Email" });
                    <span> Tìm Theo </span>@Html.DropDownList("SearchBy", SearchBy, new { @class = "select" });

                    <input type="submit" value="Tìm Kiếm" />
                }

            </div>
            @if (Model.Count > 0)
            {
                using (Html.BeginForm("Multi_Delete", "BookCar", FormMethod.Post))
                {
                    <table class="tablesorter" cellpadding="0" cellspacing="0">
                        <thead>
                            <tr>
                                <th style="text-align: center">Chọn</th>
                                <th style="text-align: center">Mã Đặt Xe</th>
                                <th style="text-align: center">Mã Xe</th>
                                <th style="text-align: center">Họ Tên</th>
                                <th style="text-align: center">Điện Thoại</th>
                                <th style="text-align: center">Email</th>
                                <th style="text-align: center">Ngày Đặt Xe</th>
                                <th style="text-align: center">Trạng Thái</th>
                                <th style="text-align: center"></th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var car in Model)
                            {
                                <tr>
                                    <td style="text-align: center; width: 3%;"><input type="checkbox" name="DatXeIdsToDelete" id="DatXeIdsToDelete" value="@car.DatXeId"></td>
                                    <td style="width: 8%; text-align: center">@car.DatXeId</td>
                                    <td style="width: 7%; text-align: center">@car.XeId</td>
                                    <td style="width:18%; text-align: center">@car.HoTen</td>
                                    <td style="width: 15%; text-align: center">@car.DienThoai</td>
                                    <td style="width: 20%; text-align: center">@car.Email</td>
                                    <td style="width: 10%; text-align: center">@String.Format("{0:dd/MM/yyyy}", car.NgayDatXe)</td>
                                    <td style="width: 9%; text-align: center">
                                        @if (@car.Duyet == true)
                                        {
                                            <span>Đã Duyệt</span>
                                        }
                                        else
                                        {   <span>Chưa Duyệt</span> }
                                    </td>
                                    <td style="width:70px" ; text-align:center ; padding-left:5px>
                                        <a class="tableActionButton check" rel="tooltip-top" title="Đã Xem" href="@Url.Action("Accept","BookCar",new {id=@car.DatXeId})" onclick="return AcceptConfirm()"></a>

                                        <a class="tableActionButton delete" rel="tooltip-top" title="Hủy" href="@Url.Action("Delete","BookCar",new {id=@car.DatXeId})" onclick=" return deleteconfirm()"></a>
                                    </td>
                                </tr>
                            }
                        </tbody>

                    </table>
                    <input type="submit" value=" Xóa Tùy Chọn " onclick="return DeleteConfirm()" />
                }
                <table cellpadding="0" cellspacing="0" style="width:100%; border-top:none; margin-top:-3px ">
                    <tr>
                        <td style="width:65px; text-align:right; font-weight:bold;padding-top:2px ">
                            <span style="border: 1px solid #808080; border-right: none; padding: 7px 15px; margin-top: 10px; border-radius: 4px 0 0 4px; background-color: #428bca; color:#ffffff"> Trang</span>
                        </td>
                        <td>@Html.PagedListPager(Model, page => Url.Action("Default", new { page, rd = ViewBag.record }), new PagedListRenderOptions() { LinkToFirstPageFormat = "<<", LinkToPreviousPageFormat = " < ", LinkToNextPageFormat = " > ", LinkToLastPageFormat = ">>" })</td>
                    </tr>
                </table>
            }
            else
            {
                <span>&nbsp &nbsp Không tìm thấy từ khóa cần tìm có dữ liệu ...!</span>
            }
        </div>
    </div>
</div>

<script>
    function DeleteConfirm() {
        if (confirm("Bạn có thật sự muốn xóa không?"))
            return true;
        else
            return false;
    }

    function AcceptConfirm() {
        if (confirm("Bạn có muốn đăng ý kiến khách hàng?"))
            return true;
        else
            return false;
    }

    function SelectedIndexChanged() {
        $('#Form').submit();
    }
</script>
@*@using PagedList;
@using PagedList.Mvc;
@model IPagedList<Project_2._2.Models.DatXe>
@{
    ViewBag.Title = "Quản Lý Đặt Xe";
    Layout = "~/Views/Shared/_AdminLayoutPage.cshtml";
}

<link href="~/Content/Admin-content-right.css" rel="stylesheet" />
<script src="~/Script/Jquery_Table_Sort/jquery-latest.js"></script>
<script src="~/Script/Jquery_Table_Sort/jquery.tablesorter.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $("table").tablesorter({ sortList: [[0, 0]], headers: { 10: { sorter: false } } });
    });

</script>

<style>
    .search {
        width: 100%;
        height: 40px;
        padding: 10px 0 10px 10px;
        float: left;
    }
</style>

<div class="grid_12">
    <div class="block-border">
        <div class="block-header">
            Quản Lý Đặt Xe
        </div>
        <div class="block-content" style="overflow:scroll">

            <div class="search">

                @using (Html.BeginForm("Default", "BookCar", FormMethod.Post, new { id = "Form" }))
                {
                    List<SelectListItem> record = new List<SelectListItem>();
                    int macdinh = 0;
                    if (ViewBag.record != null)
                    {
                        macdinh = int.Parse(ViewBag.record);
                    }
                    else
                    {
                        macdinh = 10;
                    }
                    for (int i = 10; i <= 50; i+=5)
                    {
                        if (macdinh == i)
                        { record.Add(new SelectListItem { Text = i + " Dòng", Value = i.ToString(), Selected = true }); }
                        else
                        { record.Add(new SelectListItem { Text = i + " Dòng", Value = i.ToString() }); }
                    }

                    <span>Hiển Thị  </span> @Html.DropDownList("soDong", record, new { @class = "select", onchange = "SelectedIndexChanged()" })

                    <span style="padding:0 10px 0 290px"> Từ Khóa </span> @Html.TextBox("KeyWord", null, new { @class = "Textbox", @placeholder = "Nhập từ khóa ..." })
                    List<SelectListItem> SearchBy = new List<SelectListItem>();
                    SearchBy.Add(new SelectListItem { Text =" Mã Đặt Xe", Value = "DatXeId", Selected = true });
                    SearchBy.Add(new SelectListItem { Text = "Tên Khách Hàng", Value = "HovaTen" });
                    <span> Tìm Theo </span>@Html.DropDownList("SearchBy", SearchBy, new { @class = "select" });
                    
                    <input type="submit" value="Tìm Kiếm" class="button" />
                }

            </div>
            @if (Model.Count > 0)
            {
                using (Html.BeginForm("Multi_Delete", "Advertise", FormMethod.Post))
                {
                    <table class="tablesorter" cellpadding="0" cellspacing="0">
                        <thead>
                            <tr>
                                <th style="text-align: center">Chọn</th>
                                <th style="text-align: center">Mã Đặt Xe</th>
                                <th style="text-align: center">Mã Xe</th>
                                <th style="text-align: center">Họ Tên</th>
                                <th style="text-align: center">Điện Thoại</th>
                                <th style="text-align: center">Email</th>
                                <th style="text-align: center">Ngày Đặt Xe</th>
                                <th style="text-align: center">Trạng Thái</th>
                                <th style="text-align: center"></th>
                            </tr>
                        </thead>
                        <tbody>

                            @foreach (var car in Model)
                            {
                                <tr>
                                    <td style="text-align: center; width: 3%;"><input type="checkbox" name="advertiseIdsToDelete" id="advertiseIdsToDelete" value="@car.DatXeId"></td>
                                    <td style="width: 8%; text-align: center">@car.DatXeId</td>
                                    <td style="width: 7%; text-align: center">@car.XeId</td>
                                    <td style ="width:18%; text-align: center">@car.HoTen</td>
                                    <td style="width: 15%; text-align: center">@car.DienThoai</td>
                                    <td style="width: 20%; text-align: center">@car.Email</td>
                                    <td style="width: 10%; text-align: center">@String.Format("{0:dd/MM/yyyy}", car.NgayDatXe)</td>
                                    <td style="width: 9%; text-align: center">
                                        @if (@car.Duyet == true)
                                        {
                                            <span>Đã Duyệt</span>
                                        }
                                        else
                                        {   <span>Chưa Duyệt</span> }
                                    </td>
                                    <td style="width:70px">
                                        <a class="tableActionButton edit" rel="tooltip-top" title="Cập Nhật" href="@Url.Action("Update", "Advertise", new { id = car.DatXeId })"></a>

                                        <a class="tableActionButton delete" rel="tooltip-top" title="Xóa" href="../Advertise/Delete/@car.DatXeId" onclick="return DeleteConfirm()"></a>
                                    </td>
                                </tr>
                            }

                        </tbody>
                    </table>
                    <input type="submit" value=" Xóa Tùy Chọn " onclick="return DeleteConfirm()" />
                }
                <table cellpadding="0" cellspacing="0" style="width:100%; border-top:none; margin-top:-3px ">

                    <tr>
                        <td></td>
                        <td style="width:65px; text-align:right; font-weight:bold;padding-top:2px ">
                            <span style="border: 1px solid #808080; border-right: none; padding: 7px 15px; margin-top: 10px; border-radius: 4px 0 0 4px ; background-color: #428bca; color:#ffffff"> Trang</span>
                        </td>
                        <td style="text-align:left">@Html.PagedListPager(Model, page => Url.Action("Default", new { page, rd = ViewBag.record }), new PagedListRenderOptions() { LinkToFirstPageFormat = "<<", LinkToPreviousPageFormat = " < ", LinkToNextPageFormat = " > ", LinkToLastPageFormat = ">>" })</td>
                    </tr>
                </table>
            }
            else
            {
                <span>Không có dữ liệu .</span>
            }
        </div>
    </div>
</div>
<script>

    function DeleteConfirm() {
        if (confirm("Bạn có thật sự muốn xóa không?"))
            return true;
        else
            return false;
    }

    function SelectedIndexChanged() {
        $('#Form').submit();
    }
</script>*@
